<?php
//No direct access
defined('_JEXEC') or die('Restricted access');

jimport('joomla.application.component.controller');

class OwnserviceControllerReportTransfer extends OwnserviceController
{
	/**
	 * Controller constructor
	 *
	 * @since 1.0
	 */
	function __construct() 
	{
		parent::__construct();
	}

	/**
	 * Method to get report transfer
	 *
	 * @return void
	 * @since 1.0
	*/
	function reporttransfer()
	{
		global $mainframe;

		//Check for request forgeries
		JRequest::checkToken() or jexit('Invalid Token');

		// Initialise variables
		$user			= & JFactory::getUser();
		$ownuser	= & Ownservice::getUser();
		$gid			= $user->gid;

		if($gid < 25) {
			if ( !(Ownservice::checkAccess('printreport', 'manage')) ) {
				//JError::raiseError( 403, JText::_("ALERTNOTAUTH") );
				JError::raiseWarning(500, JText::_('ALERTNOTAUTH') );
				$mainframe->redirect(JRoute::_('index.php?option=com_ownservice'));
			}
		}

		//Get var
		$period	= JRequest::getVar('period', 1, 'post', 'int');

		// Create the view
		$view		= & $this->getView('reporttransfer', 'html');

		// Get/Create the model
		$model = & $this->getModel('ReportTransfer');

		// Push the model into the view (as default)
		$view->setModel($model, true);

		// Set the layout
		$layout = $period==1?'todayreport':'monthlyreport';

		$view->setLayout($layout);

		// Display the view
		$view->display();
	}

	function listDetailSession()
	{
		global $mainframe;

		//Check for request forgeries
		JRequest::checkToken() or jexit('Invalid Token');

		// Initialise variables
		$user			= & JFactory::getUser();
		$ownuser	= & Ownservice::getUser();
		$gid			= $user->gid;

		if($gid < 25) {
			if ( !(Ownservice::checkAccess('printreport', 'manage')) ) {
				//JError::raiseError( 403, JText::_("ALERTNOTAUTH") );
				JError::raiseWarning(500, JText::_('ALERTNOTAUTH') );
				$mainframe->redirect(JRoute::_('index.php?option=com_ownservice'));
			}
		}

		// Create the view
		$view		= & $this->getView('reporttransfer', 'html');

		// Get/Create the model
		$model = & $this->getModel('ReportTransfer');

		// Push the model into the view (as default)
		$view->setModel($model, true);

		// Set the layout
		$layout = 'details';

		$view->setLayout($layout);

		// Display the view
		$view->display();
	}

}